package etl;

import java.io.EOFException;
import java.sql.SQLException;
import backend.*;

public class SchemaImporter {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		System.out.println("ETL Tool readying data set import...");
		
		Warehouse wh = new Warehouse();
		
		Extractor ext = new Extractor();
		Transformer tra = new Transformer(wh);
		
		try {
			wh.open();
			ext.connect();
			
			ext.setLastReadingId(4316824);
			
			ReadingData dataRow;
			
			while (true)
			{
				dataRow = null;
				try
				{
					dataRow = ext.extractNextRow();
				}
				catch (EOFException e)
				{
					break;
				}
				
				if (dataRow == null)
				{
					continue;
				}
				tra.transform(dataRow);
			}
			
			ext.disconnect();
			wh.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		System.out.print("ETL Tool execution finished -- exiting.");
		
	}

}
